
//
//  PullingRefreshView.swift
//  SinaBlog
//
//  Created by 有何不可 on 16/1/8.
//  Copyright © 2016年 有何不可. All rights reserved.
//

import UIKit

class PullingRefreshView: UIView {

    @IBOutlet weak var pullingView: UIView!

    @IBOutlet weak var pullArrowImgView: UIImageView!

    @IBOutlet weak var loadingImgView: UIImageView!
    
    func loadingAnimation() {
        
        let animation = CABasicAnimation(keyPath: "transform.rotation")
        
        animation.toValue = 2 * M_PI
        
        animation.repeatCount = MAXFLOAT
        
        animation.duration = 2.0
        
        animation.removedOnCompletion = false
        
        loadingImgView.layer.addAnimation(animation, forKey: "loadingAnimation")
    }
    
    func removeAnimation() {
        
        loadingImgView.layer.removeAllAnimations()
    }
    
    func pullAnimation() {
        
     UIView.animateWithDuration(0.7) { () -> Void in
        
        self.pullArrowImgView.transform = CGAffineTransformRotate(self.pullArrowImgView.transform, CGFloat(M_PI))
        
        }
    }
    
}
